If forget to add a limit, the pod will try to consume all system resources.

[Create the Namespace]
$ kubectl apply -f Namespace_1.yaml
namespace/development created

[Create the LimitRange]
$ kubectl create -f LimitRange_1.yml
limitrange/blog-limitrange created

[Describe the LimitRange]
$ kubectl describe limitranges -n development
Name:       blog-limitrange
Namespace:  development
Type        Resource  Min  Max  Default Request  Default Limit  Max Limit/Request Ratio
----        --------  ---  ---  ---------------  -------------  -----------------------
Pod         memory    -    1Gi  -                -              -
Pod         cpu       -    1    -                -              -

[Create the Pod]
$ kubectl create -f Pod_1.yaml
Error from server (Forbidden): error when creating "Pod_1.yaml": pods "cpu-problem-nginx" is forbidden: [maximum cpu usage per Pod is 1, but limit is 2, maximum memory usage per Pod is 1Gi.  No limit is specified]
$ kubectl create -f Pod_2.yaml
Error from server (Forbidden): error when creating "Pod_2.yaml": pods "memory-problem-nginx" is forbidden: [maximum cpu usage per Pod is 1.  No limit is specified, maximum memory usage per Pod is 1Gi, but limit is 2147483648]

The maximum CPU core was never mentioned in the Pod_2.yaml file. As a result, this pod will attempt to utilise all available CPUs. However, in the Limit Range, we set 1 CPU Core.
The memory-problem-nginx pod is attempting to allocate 2 GiB of Memory which is in excess of the memory limit.

[Create the Pod]
$ kubectl create -f Pod_3.yaml
Error from server (Forbidden): error when creating "Pod_3.yaml": pods "memory-problem-nginx" is forbidden: maximum memory usage per Pod is 1Gi, but limit is 2147483648
$ kubectl create -f Pod_4.yaml
pod/good-nginx created

[List the Pods]
$ kubectl get pods -n development
NAME                 READY   STATUS    RESTARTS   AGE
good-nginx           1/1     Running   0          6s


➤ Multiple Containers in One Pod

[Create the Pod]
$ kubectl create -f Pod_5.yaml
Error from server (Forbidden): error when creating "Pod_5.yaml": pods "bad-nginx-redis" is forbidden: [maximum memory usage per Pod is 1Gi, but limit is 2147483648, maximum cpu usage per Pod is 1, but limit is 2]

Kubernetes throws an error when each container wants to allocate 1 GiB of Memory and use 1 CPU Core. 
We have a 1 GiB of memory and 1 CPU core limit per Pod. We require two CPU cores and two gigabytes of memory in the Pod_5.yaml file.

[Create the Pod]
$ kubectl create -f Pod_6.yaml
pod/good-nginx-redis created

[List the Pods]
$ kubectl get pods -n development
NAME               READY   STATUS    RESTARTS   AGE
good-nginx-redis   2/2     Running   0          23s

[Delete the LimitRange]
$ kubectl delete -f LimitRange_1.yml
limitrange "blog-limitrange" deleted

[Create the LimitRange]
$ kubectl create -f LimitRange_2.yml
limitrange/blog-limitrange created

[Describe the LimitRange]
$ kubectl describe limitranges -n development
Name:       blog-limitrange
Namespace:  development
Type        Resource  Min  Max  Default Request  Default Limit  Max Limit/Request Ratio
----        --------  ---  ---  ---------------  -------------  -----------------------
Container   cpu       -    1    1                1              -
Container   memory    -    1Gi  1Gi              1Gi            -

Let’s try to deploy Pod_5.yaml file again.

[Create the Pod]
$ kubectl create -f Pod_5.yaml
pod/bad-nginx-redis created

[List the Pods]
$ kubectl get pods -n development
NAME              READY   STATUS    RESTARTS   AGE
bad-nginx-redis   2/2     Running   0          33s

It has been successfully deployed. Because the Limit type is Container, not Pod. Each container is limited to 1 GiB of Memory and 1 CPU Core.

[Delete the LimitRange]
$ kubectl delete limitranges blog-limitrange -n dev
limitrange "blog-limitrange" deleted


➤ Assign default limits

[Create the LimitRange]
$ kubectl create -f LimitRange_3.yml
limitrange/blog-limitrange created

[Describe the LimitRange]
$ kubectl describe limitranges -n development
Name:       blog-limitrange
Namespace:  development
Type        Resource  Min   Max  Default Request  Default Limit  Max Limit/Request Ratio
----        --------  ---   ---  ---------------  -------------  -----------------------
Container   cpu       100m  1    250m             500m           -
Container   memory    32Mi  1Gi  64Mi             128Mi          -

Let’s deploy a pod without specifying any limits.

[Create the Pod]
$ kubectl create -f Pod_7.yaml
pod/default-nginx created

[List the Pods]
$ kubectl describe pod/default-nginx -n development
Name:         default-nginx
Namespace:    development
...
    Limits:
      cpu:     500m
      memory:  128Mi
    Requests:
      cpu:        250m
      memory:     64Mi
...

When using Type Pod, you cannot specify default or defaultRequest in LimitRange.
